﻿@model SearchModel
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Search").Text);
}
@using Nop.Web.Models.Catalog;
@using Nop.Web.Extensions;
<div class="page search-page">
    <div class="page-title">
        <h1>@T("Search")</h1>
    </div>
    <div class="clear">
    </div>
    <div class="page-body">
        @using (Html.BeginRouteForm("ProductSearch", FormMethod.Get))
        {
            <div class="search-input">
                <script type="text/javascript">
                    $(document).ready(function () {

                        $("#@Html.FieldIdFor(model => model.As)").click(toggleAdvancedSearch);

                        toggleAdvancedSearch();
                    });

                    function toggleAdvancedSearch() {

                        if ($('#@Html.FieldIdFor(model => model.As)').is(':checked')) {
                            $('#advanced-search-block').show();
                        }
                        else {
                            $('#advanced-search-block').hide();
                        }
                    }

                </script>
                <table class="basic-search">
                    <tbody>
                        <tr>
                            <td class="title">
                                @Html.LabelFor(model => model.Q):
                            </td>
                            <td class="data">
                                @Html.TextBoxFor(model => model.Q, new { @class = "search-text" })
                            </td>
                        </tr>
                        @Html.Widget("productsearch_page_basic")
                        <tr>
                            <td class="title" colspan="2">
                                @Html.CheckBoxFor(model => model.As)
                                @Html.LabelFor(model => model.As)
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <table class="adv-search" id="advanced-search-block">
                                    <tbody>
                                        @if (Model.AvailableCategories.Count > 0)
                                        {
                                            <tr>
                                                <td class="title">
                                                    @Html.LabelFor(model => model.Cid):
                                                </td>
                                                <td class="data">
                                                    @Html.DropDownListFor(model => model.Cid, Model.AvailableCategories)
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="data" colspan="2">
                                                    @Html.CheckBoxFor(model => model.Isc)
                                                    @Html.LabelFor(model => model.Isc)
                                                </td>
                                            </tr>
                                        }
                                        @if (Model.AvailableManufacturers.Count > 0)
                                        {
                                            <tr>
                                                <td class="title">
                                                    @Html.LabelFor(model => model.Mid):
                                                </td>
                                                <td class="data">
                                                    @Html.DropDownListFor(model => model.Mid, Model.AvailableManufacturers)
                                                </td>
                                            </tr>
                                        }
                                        <tr>
                                            <td class="title">
                                                @T("Search.PriceRange"):
                                            </td>
                                            <td class="data">
                                                @T("Search.PriceRange.From")
                                                @Html.TextBoxFor(model => model.Pf, new { @class = "price-from" })
                                                @T("Search.PriceRange.To")
                                                @Html.TextBoxFor(model => model.Pt, new { @class = "price-to" })
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="data" colspan="2">
                                                @Html.CheckBoxFor(model => model.Sid)
                                                @Html.LabelFor(model => model.Sid)
                                            </td>
                                        </tr>
                                        @Html.Widget("productsearch_page_advanced")
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" class="buttons">
                                <input type="submit" class="button-1 search-button" value="@T("Search")" />
                            </td>
                        </tr>
                        @if (!String.IsNullOrEmpty(Model.Warning))
                        {
                            <tr>
                                <td colspan="2">
                                    <span class="warning">
                                        @Model.Warning
                                    </span>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <div class="clear">
            </div>
            <div class="search-results">
                @if (Model.NoResults)
                {
                    <span class="result">
                        @T("Search.NoResultsText")
                    </span>
                }
                <div class="product-list">
                    @*list mode*@
                    <div class="product-list">
                        @foreach (var product in Model.Products)
                        {
                            <div class="item-box">
                                @Html.Partial("_ProductBox", product)
                            </div>
                        }
                    </div>
                </div>
                <div class="clear">
                </div>
                <div class="pager">
                    @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber").BooleanParameterName("as").BooleanParameterName("isc").BooleanParameterName("sid")
                </div>
            </div>
        }
    </div>
</div>
